<?php 
  /**
    * FILE:          cieSearch.php
    * LOCATION:      /root/
    * REFERENCES:    admin.php
    * FUNCTION:      allows a user to search for consumer. renders a resultset in cieEdit.php
    * DEPENDENCIES:  cieList.php
    *                					cieEdit.php
    * ==============================================================================
    * 
    * @version $Id: cieSearch.php,v 0.1 2008/08/08
    * @copyright Copyright (c) none
    * @author chrisv
    * @license http://opensource.org/licenses/gpl-license.php GNU General 
    * Public License Version 2  (GPL V2)
    * 
    * ==============================================================================
    */
		
	//lets initialize our dependency files
	require_once('./core_lib/core_functions.php');
?>
	<script type="text/javascript" src="./script/jquery-1.2.1.pack.js"></script>
	<script type="text/javascript">
		function lookup(inputString) {
			if(inputString.length == 0) {
				// Hide the suggestion box.
				$('#suggestions').hide();
			} else {
				$.post("./actions/ProcessAjaxSearch.php", {queryString: ""+inputString+""}, function(data){
					if(data.length >0) {
						$('#suggestions').show();
						$('#autoSuggestionsList').html(data);
					}
				});
			}
		} // lookup
		function fill(thisValue) {
			$('#inputString').val(thisValue);
			setTimeout("$('#suggestions').hide();", 200);
		}
</script>
<fieldset>
	<h1 style="font-size:2.3em;font-weight:bold;
									background-image:url('./images/search.png');
									background-repeat:no-repeat;
									line-height:2em;
									padding-left:60px;"><strong>SEARCH: </strong> Consumer Case File Entries</h1>
  <?php 
      $error = sanitize($_GET['error']);
      if($error) {
					echo "<div class='error'>".$error."</div>";
      }
?>  
	<!-- AJAX SEARCH FORM -->
	<form class="gt-form" 
				style="width: 100%; margin-bottom: 20px;">
	<div style="background:#F7F8E0; border:5px solid #424242;padding:15px;">
			<h2 style="font-weight:bold; font-size: 1.5em;
											background-image:url('./images/quick_search.png');
											background-repeat:no-repeat;
											line-height:3em;
											float:left;
											padding-left:50px;
											padding-right:20px;">Quick Find</h2>
			<label>
			Enter a consumer's first name in text box #1.  Allow the server to respond with possible 
			consumer file suggestions. The suggestions provided below are saved in the database, so 
			you may not need to create a new file.  If you find the needed consumer file, move your mouse over 
			the consumer's name in the black bubble and click it.  You will be taken to that file hosted on 
			another page.
			</label>
			<br />
			<h2 style="float:left;
											font-weight:bold;
											padding:1px;
											margin-right: 15px;
											color: #fff;
											background-color: #424242;
											border: 3px solid #848484;
											">#1</h2>
			<input class="data" type="text" 
							style="width: 250px; border:4px solid #6CAA00;" 
							value="" id="inputString" onkeyup="lookup(this.value);" onblur="fill();" />
			</div>
			<div class="suggestionsBox" id="suggestions" style="display: none;">
				<img src="./images/upArrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
				<div class="suggestionList" id="autoSuggestionsList">
					&nbsp;
				</div>
			</div>
	</form>
  <!-- CONSUMER SEARCH FORM -->
  <form class="gt-form" 
				style="width: 100%;"
				action="admin.php?action=cielistquery" 
				method="post">
	<div style="background:#eee; border:5px solid #424242;padding:15px;">
			<h2 style="font-weight:bold; font-size: 1.5em;
											background-image:url('./images/pencil.png');
											background-repeat:no-repeat;
											line-height:3em;
											padding-left:70px;">Query-Based Search Options</h2>
			<label>
					Use this form as your <strong>search engine</strong> for the consumer database.
					Enter the consumer information you want to find.  Then preview your search results on the 
					next page. Here's how it works:<br />
						<ol>
							<li>Enter a search keyword in the box #2.</li>
							<li>Then pick the search parameter you want to send.   You can search the database system
										by: 
										<strong>[1.] Last Name,  [2.] First Name,  [3.] City,  [4.] State</strong>
							</li>
						</ol>
			</label>
			<hr />
			<!-- search box -->
			<div id="formUnit">
                   <label style="margin-left: 50px;">Search String</label>
			<h2 style="float:left;
											font-weight:bold;
											padding:1px;
											margin-right: 15px;
											color: #fff;
											background-color: #424242;
											border: 3px solid #848484;
											">#2</h2>
                   <input type="text" class="data" style="width: 250px;border:4px solid #585858;" name="searchStr" value=""/>
			<!-- search match option -->
				<span style="margin-top:-55px;float:right; margin-right:400px;">
				<label>Search Parameter</label>
					<select name="searchAttr" class="data" style="border:4px solid #585858;">
						<option value="false">Choose Option</option>
						<option value="lName">Last Name</option>
						<option value="fName">First Name</option>
						<option value="city">City</option>
						<option value="phone">Phone</option>
					</select>
					</span>
			</div>
			<br/>
			<div id="formUnit">
             <input class="btn"
								type="submit"
								style="background-color: #fff;
														background-image:url('./images/gt/btn-blank-long.jpg');
													 background-repeat:no-repeat;
													 border:none;
													 width:160px;
													 height: 30px;
													 color: #fff;
													 font-weight:bold;"
								name="Search"
								value="Search">
			</div>
	</div>
</form>
<!-- end consumer query-based search form-->
<div class="gt-notice-box2" style="margin-top: 20px;">
<h2 style="margin-top: 20px; font-weight:bold;">Still Can't Find The File You Need?</h2>
    <p style="color:#000; font-weight:bold;font-size:1.2em;">
		If you have searched for a certain case file but can not find it, then click on the "See All Case Files" button
		to see every file in the database.  If you just want to create a new file, click on the "Create New File" button.
	</p>
	<p>
				<!-- notice that to create new consumer id, id is set to 0 --> 
				<a style="background-image:url('./images/gt/btn-blank-long.jpg');
											background-repeat:no-repeat;
											border:none;
											line-height:3em;
											margin-right:30px;
											padding:7px 25px 7px 25px;
											width:160px;
											height: 30px;
											color: #fff;
											font-weight:bold;
											text-decoration:none;" 
							class="btn"
						href="admin.php?action=cielistall">
						<strong>See All Case Files</strong>
			</a>
    <!-- option to create new record -->
       <!-- notice that to create new consumer id, id is set to 0 -->
				<a style="background-image:url('./images/gt/btn-blank-long.jpg');
											background-repeat:no-repeat;
											border:none;
											line-height:3em;
											padding:7px 25px 7px 15px;
											width:160px;
											height: 30px;
											color: #fff;
											font-weight:bold;
											text-decoration:none;" 
							class="btn" href="admin.php?action=cieedit&id=0">
				<strong>Create New Case File</strong>
		</a>
    </p>
</div>